import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { Cache } from "../../../cache/Cache";
import { EActiveType } from "../../../../../Message/Public/EActiveType";
import { GuildCopyEntrancePanel } from "./entrance/GuildCopyEntrancePanel";
import { GameProxy } from "../../../mvc/GameProxy";
import { GuildDefenseEntrancePanel } from "./entrance/GuildDefenseEntrancePanel";
import { GuildRobCityEntrancePanel } from "./entrance/GuildRobCityEntrancePanel";
import { GuildEliteCopyEntrancePanel } from "./entrance/GuildEliteCopyEntrancePanel";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
import { GuildCopyEntrancePanelBase } from "./entrance/GuildCopyEntrancePanelBase";
import { _ECopyGuildStruggle } from "../../../../../ECopyType/_ECopyGuildStruggle";
import { _ECopyGuildDefense } from "../../../../../ECopyType/_ECopyGuildDefense";
import { _ECopyRobCityOne } from "../../../../../ECopyType/_ECopyRobCityOne";
import { _ECopyGuildElite } from "../../../../../ECopyType/_ECopyGuildElite";
type int = number;
//class OpenGuildCopyWindow
    
    export  class OpenGuildCopyWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            this._tabData = [{"name":"", "type": _ECopyGuildStruggle, "label": Language.getString(60437)}, {"name":"", "type": _ECopyGuildDefense, "label": Language.getString(60438)}];
            super(arg1);
            this.setSize(342, 398);
            this.title = Language.getString(60400);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 92, 305, 254, this);
            if (Cache.instance.active.isActiveInEffect(EActiveType._EActiveTypeCrossRobCityOne)) 
            {
                this._tabData.push({"name":"", "type": _ECopyRobCityOne, "label": Language.getString(60920)});
            }
            this._tabData.push({"name":"", "type": _ECopyGuildElite, "label": Language.getString(60600)});
            this._tabBar = ObjCreate.createGTabBar(16, 34, this._tabData, 63, 22, this, this.onTabBarChangeHandler);
            this.showToEntrance(ECopyType._ECopyGuildStruggle);
            return;
        }

        /* internal  */onTabBarChangeHandler(arg1): void
        {
            this.showToEntrance(this._tabBar.selectedItem["type"]);
            return;
        }

        public showToEntrance(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            if (!this._tabBar.selectedItem || !(this._tabBar.selectedItem["type"] == arg1)) 
            {
                loc2 = 0;
                while (loc2 < this._tabData.length) 
                {
                    if (this._tabData[loc2]["type"] == arg1) 
                    {
                        this._tabBar.selectedIndex = loc2;
                    }
                    ++loc2;
                }
            }
            if (this._curEntrance && this._curEntrance.parent) 
            {
                this._curEntrance.parent.removeChild(this._curEntrance);
            }
            var loc3=arg1;
            switch (loc3) 
            {
                case ECopyType._ECopyGuildStruggle:
                {
                    if (!this._guildCopy) 
                    {
                        this._guildCopy = new GuildCopyEntrancePanel();
                    }
                    this._curEntrance = this._guildCopy;
                    GameProxy.copy.getGuildStruggleInfo();
                    break;
                }
                case ECopyType._ECopyGuildDefense:
                {
                    if (!this._guildDefense) 
                    {
                        this._guildDefense = new GuildDefenseEntrancePanel();
                    }
                    this._curEntrance = this._guildDefense;
                    break;
                }
                case ECopyType._ECopyRobCityOne:
                {
                    if (!this._guildRobCity) 
                    {
                        this._guildRobCity = new GuildRobCityEntrancePanel();
                    }
                    this._curEntrance = this._guildRobCity;
                    break;
                }
                case ECopyType._ECopyGuildElite:
                {
                    if (!this._guildElite) 
                    {
                        this._guildElite = new GuildEliteCopyEntrancePanel();
                    }
                    this._curEntrance = this._guildElite;
                    break;
                }
            }
            if (this._curEntrance) 
            {
                this._curEntrance.updateStatus();
                this.addChild(this._curEntrance);
            }
            return;
        }

        public updateStatus(): void
        {
            this._curEntrance.updateStatus();
            return;
        }

        /* internal */ /* var */_tabData: Array<any>;

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_curEntrance: GuildCopyEntrancePanelBase;

        /* internal */ /* var */_guildCopy: GuildCopyEntrancePanel;

        /* internal */ /* var */_guildDefense: GuildDefenseEntrancePanel;

        /* internal */ /* var */_guildRobCity: GuildRobCityEntrancePanel;

        /* internal */ /* var */_guildElite: GuildEliteCopyEntrancePanel;
    }
